package cn.wzptsoft.mall.service.Impl;

import cn.hutool.core.bean.BeanUtil;
import cn.wzptsoft.mall.mapper.ThemeMapper;
import cn.wzptsoft.mall.mapper.UserMapper;
import cn.wzptsoft.mall.pojo.Theme;
import cn.wzptsoft.mall.pojo.ThemeSpu;
import cn.wzptsoft.mall.pojo.User;
import cn.wzptsoft.mall.pojo.vo.ThemeVo;
import cn.wzptsoft.mall.service.IThemeService;
import cn.wzptsoft.mall.service.IUserService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class IThemeServiceImpl extends ServiceImpl<ThemeMapper, Theme> implements IThemeService {
    @Override
    public List<ThemeVo> listByNames(List<String> list) {
        //查询所有的theme
        List<Theme> themes = lambdaQuery().in(Theme::getName, list).list();
        //封装到vo
        List<ThemeVo> themeVos = themes.stream().map(s -> BeanUtil.copyProperties(s, ThemeVo.class)).toList();
        return themeVos;
    }

    @Override
    public List<String> getNames() {
        LambdaQueryWrapper<Theme> wrapper=new LambdaQueryWrapper<>();
        wrapper.select(Theme::getName);
        List<Theme> themes = list(wrapper);
        List<String> list = themes.stream().
                map(Theme::getName).
                collect(Collectors.toList());
        return list;
    }
}
